﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CrystalDecisions.CrystalReports.Engine;
using System.Data;
using LPV_POS.Baocao;
using LPV_POS.Baocao.Ellic;

public class Mod_baocaodoanhthu_hienhanh
{
    public void f_baocaodoanhthu_hienhanh(string loaibaocao, DataSet _dsbaocao, DevExpress.XtraGrid.GridControl luoi_doanhthu, DataTable dt_bcThe) // bc httt, editor: PL, date: 2012.07.25
    {
        mh_save frm_save = new mh_save("Baocao_hienhanh" + DateTime.Now.ToString("yyMMdd_HHmmss"));
        frm_save.ShowDialog();
        if (frm_save.path_excel == "")
            return;
        ReportDocument CrReport;
        Mod_header_report header_report = new Mod_header_report();
        switch (loaibaocao)
        {

            case "nhomchu":
                CrReport = new bc_nhomchu();
                header_report.f_header_report(CrReport);
                Mod_baocaonhomchu baocaonhomchu = new Mod_baocaonhomchu();
                baocaonhomchu.rpt_baocaonhomchu(_dsbaocao, CrReport, frm_save.path_excel);
                break;

            case "nhomhang":
                CrReport = new bc_nhomhang();
                header_report.f_header_report(CrReport);
                Mod_baocaonhomhang baocaonhomhang = new Mod_baocaonhomhang();
                baocaonhomhang.rpt_baocaonhomhang(_dsbaocao, CrReport, frm_save.path_excel);
                break;

            case "mathang":
                CrReport = new bc_hanghoa();
                header_report.f_header_report(CrReport);
                Mod_baocaohanghoa baocaohanghoa = new Mod_baocaohanghoa();
                baocaohanghoa.rpt_baocaohanghoa(_dsbaocao, CrReport, frm_save.path_excel);
                break;

            case "baocaotheogio":
                CrReport = new bc_baocaotheogio();
                header_report.f_header_report(CrReport);
                Mod_baocaotheogio baocaotheogio = new Mod_baocaotheogio();
                baocaotheogio.rpt_baocaodoanhthutheogio(_dsbaocao, CrReport, frm_save.path_excel);
                break;

            case "NHANVIEN":
                CrReport = new bc_nhanvien();
                header_report.f_header_report(CrReport);
                Mod_baocaonhanvien baocaonhanvien = new Mod_baocaonhanvien();
                baocaonhanvien.rpt_baocaonhanvien(_dsbaocao, CrReport, frm_save.path_excel);
                break;

            case "nv_tongquat":
                CrReport = new bc_nhanvientongquat();
                header_report.f_header_report(CrReport);
                Mod_nhanvientongquat baocaonhanvientongquat = new Mod_nhanvientongquat();
                baocaonhanvientongquat.rpt_baocaonhanvientongquat(_dsbaocao, CrReport, frm_save.path_excel);
                break;

            case "nv_chitietvaora":
                CrReport = new bc_nhanvien_chitietvaora();
                header_report.f_header_report(CrReport);
                Mod_nhanvienchitietvaora baocaonhanvienvaora = new Mod_nhanvienchitietvaora();
                baocaonhanvienvaora.rpt_baocaonhanvienvaora(_dsbaocao, CrReport, frm_save.path_excel);
                break;

            case "nv_chitiet":
                CrReport = new bc_nhanvien_chitiet();
                header_report.f_header_report(CrReport);
                Mod_nhanvienchitiet baocaonhanvienchitiet = new Mod_nhanvienchitiet();
                baocaonhanvienchitiet.rpt_baocaonhanvienchitiet(_dsbaocao, CrReport, frm_save.path_excel);
                break;

            case "nv_chitietmathang":
                CrReport = new bc_nhanvien_chitietmathang();
                header_report.f_header_report(CrReport);
                Mod_nhanvienchitietmathang baocaonhanvienchitietmathang = new Mod_nhanvienchitietmathang();
                baocaonhanvienchitietmathang.rpt_baocaonhanvienchitietmathang(_dsbaocao, CrReport, frm_save.path_excel);
                break;


            case "khuvuc":
                CrReport = new bc_khuvuc();
                header_report.f_header_report(CrReport);
                Mod_baocaokhuvuc baocaokhuvuc = new Mod_baocaokhuvuc();
                baocaokhuvuc.rpt_baocaokhuvuc(_dsbaocao, CrReport, frm_save.path_excel);
                break;
            case "khuvuc_ct":
            case "ban":
                CrReport = new bc_ban();
                header_report.f_header_report(CrReport);
                Mod_baocaoban baocaoban = new Mod_baocaoban();
                baocaoban.rpt_baocaoban(_dsbaocao, CrReport, frm_save.path_excel, loaibaocao);
                break;

            case "kho":
                CrReport = new bc_khohang();
                header_report.f_header_report(CrReport);
                Mod_khohang baocaokhohang = new Mod_khohang();

                //anhlq
                DataView dv1 = _dsbaocao.Tables[0].Copy().DefaultView;
                dv1.RowFilter = @"TON_KHO_BAN_DAU <>0 
                                            OR NHAP_KHO<>0 
                                            OR XUAT_KHO<>0 
                                            OR NHAP_TRA_LAI<>0 
                                            OR BAN_RA<>0 
                                            OR BAN_RA<>0 
                                            OR TON_CUOI_KY <>0 
                                            OR LUONG_HANG_HOA_THAY_DOI<>0";
                DataSet DS1 = new DataSet();
                DS1.Tables.Add(dv1.ToTable());
                //DataSet AAA=dv1.ToTable().
                baocaokhohang.rpt_baocaokhohang(DS1, CrReport, frm_save.path_excel, luoi_doanhthu);

                break;

            case "kho_nhapxuat":
                CrReport = new bc_khohang_nhapxuat();
                header_report.f_header_report(CrReport);
                Mod_khohang_nhapxuat baocaokhohangnhapxuat = new Mod_khohang_nhapxuat();
                baocaokhohangnhapxuat.rpt_baocaokhohang_nhapxuat(_dsbaocao, CrReport, frm_save.path_excel);
                break;

            //------------------------------------------------------------------

            case "khachhang_tongquat":
                CrReport = new bc_khachhang_tongquat();
                header_report.f_header_report(CrReport);
                Mod_khachhang_tongquat baocaokhachhang_tongquat = new Mod_khachhang_tongquat();
                baocaokhachhang_tongquat.rpt_baocao_nhanvientongquat(_dsbaocao, CrReport, frm_save.path_excel);
                break;

            case "khachhang_mathang":
                CrReport = new bc_khachhang_chitietmathang();
                header_report.f_header_report(CrReport);
                Mod_khachhang_chitietmathang baocaokhachhang_chitietmathang = new Mod_khachhang_chitietmathang();
                baocaokhachhang_chitietmathang.rpt_baocao_khachhang_chitietmathang(_dsbaocao, CrReport, frm_save.path_excel);
                break;

            case "khachhang _ chitietso":
                CrReport = new bc_khachhang_chitietso();
                header_report.f_header_report(CrReport);
                Mod_khachhangchitietso baocaokhachhang_chitietso = new Mod_khachhangchitietso();
                baocaokhachhang_chitietso.rpt_baocaokhachhangchitietso(_dsbaocao, CrReport, frm_save.path_excel);
                break;

            case "Chi tiet phieu":
            case "doanh thu phieu":
                CrReport = new bc_nhanvien_phieu();
                header_report.f_header_report(CrReport);
                Mod_nhanvien_phieu baocaonhanvien_phieu = new Mod_nhanvien_phieu();
                baocaonhanvien_phieu.rpt_baocaonhanvienphieu(_dsbaocao, CrReport, frm_save.path_excel);
                break;

                //bc theo hinh thuc the, -- editor: PL, date: 2012.07.30
            case "thethanhtoan":
                CrReport = new bc_thethanhtoan();
                header_report.f_header_report(CrReport);
                Mod_baocaothethanhtoan baocaothethanhtoan = new Mod_baocaothethanhtoan();
                baocaothethanhtoan.rpt_baocaothethanhtoan(_dsbaocao, CrReport, frm_save.path_excel, dt_bcThe);
                break;
                //end 2012.07.25
            
        }
        if (System.IO.File.Exists(frm_save.path_excel))
        {
            System.Diagnostics.Process.Start(frm_save.path_excel);//mo file vừa SAVE = DOUBLE_LICK
        }
    }
}